package com.suzhiliang.springbootlesson.javaMailDemo;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Copyright (C), 2015-2018, XXX有限公司
 *
 * @ClassName: PropertiesUtil
 * @Author: xmm
 * @Date: 2018/10/18 17:14
 * @Description: *.properties配置文件的工具类
 * @Version 1.0
 */
public class PropertiesUtil {
    private final ResourceBundle resourceBundle;
    private final String fileName;

    /**
     * 构造函数初始化数据
     * @param fileName
     */
    public PropertiesUtil(String fileName) {
        Locale locale = new Locale("zh","CN");
        this.fileName = fileName;
        this.resourceBundle = ResourceBundle.getBundle(this.fileName,locale);
    }

    /**
     * 根据传入的key获取对象的值
     * @param  key
     * @return
     */
    public String getValue(String key){
        String message = this.resourceBundle.getString(key);
        return message;
    }
}
